import { getStorage,setStorage } from '@/utils/tools'
import { defineStore } from 'pinia'
import { RouteRecordRaw } from 'vue-router'
export const menusStore = defineStore({
  id: 'app-menus',
  state:()=>{
    return {
      menus:  getStorage('menus'),
      permissionAction:  getStorage('permission_action'),
      children: [],
      curNavPath:'',
      addonMenus: getStorage('addon_menus'),
    }
  },
  actions: {
    setMenus(value: any) {
      setStorage('menus',value);
      this.$patch({
        menus:value
      })
    },
    setPermissionAction(value: any) {
      setStorage('permission_action',value);
      this.$patch({
        permissionAction:value
      })
    },
    setMenuCildren(value: any){
      this.$patch({
        children:value
      })
    },
    setCurNavPath(value: any){
      this.$patch({
        curNavPath:value
      })
    },
    setAddonMenus(value: any) {
      setStorage('addon_menus',value);
      this.$patch({
        addonMenus:value
      })
    },
  },
  getters: {
    getMenus(state): any {
      return state.menus
    },
    getAddonMenus(state): any {
      return state.addonMenus
    },
    getMenuCildren(state):any{
      return state.children
    },
    getCurNavPath(state):any{
      return state.curNavPath
    },
    getPermissionAction(state): any {
      return state.permissionAction
    }
  },
})
